﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour {

	// Use this for initialization

    public float m_speed = 0.3f;

    private Animator m_PlayerAnimator;
    private SpriteRenderer m_PlayerSpriteRender;
    private Transform m_PlayerTranform;
	void Start ()
	{
        m_PlayerAnimator = GetComponent<Animator>();
	    m_PlayerSpriteRender = GetComponent<SpriteRenderer>();
	    m_PlayerTranform = GetComponent<Transform>();

	}
	
	// Update is called once per frame
	void Update () {
		
	}

    void FixedUpdate()
    {
        float h = Input.GetAxis("Horizontal");
        if (h != 0)
        {
            m_PlayerAnimator.Play("Player_Idle");
            var _postion = m_PlayerTranform.localPosition;
            _postion.x += h * m_speed;
            m_PlayerTranform.localPosition = _postion;
        }
        if (h < 0)
        {
            m_PlayerSpriteRender.flipX = true;

        }
        if (h > 0)
        {
            m_PlayerSpriteRender.flipX = false;
        }
        
    }
}
